package com.dup.factory;

import com.dup.algms.JaroWinklerMatchEx;
import com.dup.algms.PerfectMatchEx;
import com.dup.algms.SoundMatchEx;
import com.dup.algms.StdJaroWinkler;
import com.dup.algms.StdPerfectMatchEx;
import com.dup.interfaces.MatchEx;

enum AlgorithmNames {
	perfect, std_perfect, jaro_winkler, sound, std_jaro_winkler
}

public class MatchAlgmsFactory {

	private static String msg = "";

	public static String getMsg() {
		return msg;
	}

	public static void setMsg(String msgStr) {
		if(msgStr.equals("")){
			msg = "";
		}else if (!msg.equals(""))
			msg += ", ";
		MatchAlgmsFactory.msg += msgStr;
	}

	public static MatchEx getMatchInstance(String alg_name) {

		MatchEx m = null;
		
		try{
		AlgorithmNames alg = AlgorithmNames.valueOf(alg_name);

		switch (alg) {
		case perfect:
			m = new PerfectMatchEx();
			break;
		case std_perfect:
			m = new StdPerfectMatchEx();
			break;
		case jaro_winkler:
			m = new JaroWinklerMatchEx();
			break;
		case sound:
			m = new SoundMatchEx();
			break;
		case std_jaro_winkler:
			m = new StdJaroWinkler();
			break;
		}
		}catch(Exception e){
			System.out.println("Error in Rule list -- " + alg_name);
		}
		return m;
	}
}
